package com.atguigu.tingshu.user.factory.impl;

import com.atguigu.tingshu.user.factory.StrategyFactory;
import com.atguigu.tingshu.user.strategy.PaymentStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class PaymentStrategyFactory implements StrategyFactory {

    //  字符串：1001 AlbumPaymentStrategy
    //  字符串：1002 TrackPaymentStrategy
    //  字符串：1003 VipPaymentStrategy
    @Autowired
    private Map<String, PaymentStrategy> strategyMap;

    public PaymentStrategy getStrategy(String itemType) {
        //  获取策略对象
        return strategyMap.get(itemType);
    }
}